package com.ynny.chapter02.dao;

import com.ynny.chapter02.base.BaseDAO;
import com.ynny.chapter02.entity.User;

public class UserDaoImpl extends BaseDAO<User> implements UserDao {
    @Override
    public int insertUser(User user) {

        String sql = "insert into user(username,password) values (?,?)";

        int i = super.insert(sql, user.getUserName(), user.getPassword());
        return i;
    }

    @Override
    public User selectUser(String username, String password) {

        String sql = "select * from user where username=? and password=?";

        User user = selectOne(sql, username, password);

        return user;

    }

    @Override
    public User selectUserByUserName(String username) {
        String sql = "select * from user where username=?";

        User user = selectOne(sql, username);

        return user;
    }
}
